package org.javaboy.vhr.service;

import org.javaboy.vhr.mapper.EmpSalaryMapper;
import org.javaboy.vhr.model.EmpSalary;
import org.javaboy.vhr.model.Employeetrain;
import org.javaboy.vhr.model.Salary;
import org.javaboy.vhr.vo.EmpSalaryVo;
import org.javaboy.vhr.vo.EmpTrainVo;
import org.javaboy.vhr.vo.RespPageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class EmpSalrayService {
    @Autowired
    EmpSalaryMapper empSalaryMapper;

    public RespPageBean getEmployeeSalaryByPage(Integer page, Integer size, EmpSalary empSalary, Date[] beginDateScope) {
        if (page != null && size != null) {
            page = (page - 1) * size;
        }
        List<EmpSalaryVo> data = empSalaryMapper.getEmpSalaryByPage(page,size,empSalary,beginDateScope);

        Long total = empSalaryMapper.getTotal(empSalary,beginDateScope);
        RespPageBean bean = new RespPageBean();
        bean.setData(data);
        bean.setTotal(total);
        return bean;
    }

    //添加时下拉框显示
    public List<Salary> getTotalSalary(){
        return empSalaryMapper.getTotalSalary();
    }

    public int add(EmpSalary empSalary){
        return empSalaryMapper.insertSelective(empSalary);
    }

    public int updateEmpSalary(EmpSalary empSalary){
        return empSalaryMapper.updateByPrimaryKey(empSalary);
    }

    public int deleteEmpSalary(Integer id){
        return empSalaryMapper.deleteByPrimaryKey(id);
    }


}
